import "./index.less";
import Person from "@/utils/Person";
import { Button } from "antd";
import { useState, useEffect } from "react";

function HomeOne() {
  const [desc, setDesc] = useState<string>("person类的描述");
  const person = Person.getInstance();
  const person1 = Person.getInstance("sb", 22);
  const person2 = Person.getInstance("ppp", 333);

  //获取信息
  const getPersonInfo = () => {
    // setDesc(person.greet);
    setDesc(person.getInfo());
  };

  //设置信息
  const setPersonInfo = () => {
    person.setInfo("张三", 25);
  };

  useEffect(() => {
    console.log(person1 === person2 ? '是单例模式' : '不是单例模式');
  }, []);

  return (
    <>
      <div className="homeone">
        <div className="text-center">homeone路由</div>
        <div className="mt-2 mb-2">{desc}</div>
        <Button type="primary" className="mr-6" onClick={getPersonInfo}>
          获取最新的person信息
        </Button>
        <Button type="primary" onClick={setPersonInfo}>
          设置person信息
        </Button>
        <div className="pt-6">测试tailwindcss</div>
      </div>
    </>
  );
}

export default HomeOne;
